package org.jctc.els.modules.biz.controller.message;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import org.jctc.els.modules.biz.service.message.IMessageUserService;
import org.jctc.els.modules.biz.entity.message.MessageUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 消息与人员关联表 前端控制器
 * </p>
 *
 * @author lyh
 * @since 2021-02-26
 */
@Api(tags = {"消息与人员关联表"})
@RestController
@AllArgsConstructor
@RequestMapping("/message-user")
public class MessageUserController {

    private IMessageUserService messageUserService;


    @ApiOperation(value = "新增消息与人员关联表")
    @PostMapping()
    public boolean save(@RequestBody MessageUser messageUser){
        return messageUserService.save(messageUser);
    }

    @ApiOperation(value = "删除消息与人员关联表")
    @DeleteMapping("{id}")
    public boolean remove(@PathVariable("id") Long id){
        return messageUserService.remove(id);
    }

    @ApiOperation(value = "更新消息与人员关联表")
    @PutMapping()
    public boolean edit(@RequestBody MessageUser messageUser){
        return messageUserService.edit(messageUser);
    }

    @ApiOperation(value = "查询消息与人员关联表分页数据")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "pageNum", value = "页码"),
        @ApiImplicitParam(name = "pageSize", value = "每页条数")
    })
    @GetMapping()
    public Page<MessageUser> selectListByPage(@RequestParam(value = "pageNum") Integer pageNum,
                                   @RequestParam(value = "pageSize") Integer pageSize){
        return messageUserService.selectListByPage(pageNum, pageSize);
    }

    @ApiOperation(value = "根据id查询消息与人员关联表")
    @GetMapping("{id}")
    public MessageUser selectById(@PathVariable("id") Long id){
        return messageUserService.selectById(id);
    }

}
